$(document).ready(function(){
	
	$("#campus").change(function() {
		
		var campusId = this.options[this.options.selectedIndex].value;
		
		$.ajax({
			type : "get",
			url : "/dms/portal/findBuilding.do?id=" + campusId,
			dateType : "xml",
			success : changeBuilding			
			}
		);
	})
});

function changeBuilding(xmlData) {
	var building = $(xmlData);
	$("#building").attr("length", 0);
	
	building.children("building").each(function() {
	
		/*$("#building").append("<option value=/"" + $(this).find("id").text() + ">" 
				+ $(this).find("name").text() + "</option>");*/
		$("#building").append("<option value='" + $(this).find("id").text() +"'>" + $(this).find("name").text() + "</option>");
	});
			
}